package org.nanotek.util;



import java.lang.reflect.InvocationTargetException;

import org.nanotek.StringKong;
import org.springframework.stereotype.Component;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.springframework.beans.factory.annotation.Autowired;

@Component
public class StringKongBuilder {

	@Autowired
	private BeanUtilsBean beanUtilBeanCopier;


	public StringKong buildKongString(final StringKong sourceMessage){
		StringKong sk = null;
		try {
			sk = (StringKong) beanUtilBeanCopier.cloneBean(sourceMessage);
			sk.setId(Long.toString(System.currentTimeMillis()));
		}catch (NoSuchMethodException |
				InvocationTargetException |
				InstantiationException |
				IllegalAccessException e){

			throw new BuilderException(e);
		}
		return sk;
	}



	public BeanUtilsBean getBeanUtilBeanCopier() {
		return beanUtilBeanCopier;
	}


	public void setBeanUtilBeanCopier(BeanUtilsBean beanUtilBeanCopier) {
		this.beanUtilBeanCopier = beanUtilBeanCopier;
	}


}
